package com.sky.service.user.impl;

import com.sky.constant.StatusConstant;
import com.sky.entity.Category;
import com.sky.mapper.user.CategoryMapper;
import com.sky.service.user.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service("userCategoryService")
public class CategoryServiceImpl implements CategoryService {


    @Autowired
    private CategoryMapper categoryMapper;
    /**
     * 条件查询
     *
     * @param type
     * @return
     */
    @Override
    public List<Category> selectCategory(Long type) {
        // 根据type查询对应类型的表

        List<Category> categoryList = categoryMapper.selectCategory(type);
        List<Category> collect = categoryList.stream().filter(category -> Objects.equals(category.getStatus(), StatusConstant.ENABLE)).collect(Collectors.toList());
        return collect;
    }
}
